#@embedLayout()


#define content()

<form id="formId" method="post">
    <input type="hidden" name="userRole.user_id" value="#(userId)">
    <table class="table table-bordered">
        #for(role : roles)
            <tr>
                <td width="150px;">
                    <label for="#(role.roleId)">#(role.roleName)</label>
                </td>
                <td>
                    <input type="checkbox" name="role" id="#(role.roleId)" value="#(role.roleId)" #(role.get("ur_id") != null ? "checked" :"") style="margin-left: 25px;" onchange="checkSuperManagerForRole(this)">
                </td>
            </tr>
        #end
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    function privileges() {
        var url = contextRootPath + '/user/userRoleSave';

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                var checkBox = $("input[name='role']:checked");

                if (checkBox.length === 0) {
                    flag = false;
                    $.messager.alert("提示", "请选择角色");
                }

                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                var params = {};
                params.element = _datagrid;
                params.data = data;
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


